/*
 * $Id: qtcQObject.cpp 7 2010-11-07 09:07:07Z tfonrouge $
 */

#include "qtharbour.h"

#include <QObject>

HB_FUNC( QOBJECT_PARENT )
{
    QObject* object = (QObject *) xho_itemListGet_XHO( hb_stackSelfItem() );
    
    if( object )
    {
        xho_itemReturn( object->parent() );
    }
}

HB_FUNC( QOBJECT_CONNECT )
{
    QObject* object = (QObject *) xho_itemListGet_XHO( hb_stackSelfItem() );
    
    const QObject* sender = xho_par_XhoObject( 1 );
    const char* signal = hb_parc( 2 );
    
    if( HB_ISCHAR( 3 ) )
    {
        if( object )
        {
            const char* slot = hb_parc( 3 );
            Qt::ConnectionType type = HB_ISNUM( 4 ) ? (Qt::ConnectionType) hb_parni( 4 ) : Qt::AutoConnection;
            
            object->connect( sender, signal, slot, type );
        }
    }
    else
    {
        const QObject* receiver = xho_par_XhoObject( 3 );
        const char* slot = hb_parc( 4 );
        Qt::ConnectionType type = HB_ISNUM( 5 ) ? (Qt::ConnectionType) hb_parni( 5 ) : Qt::AutoConnection;
        
        QObject::connect( sender, signal, receiver, slot, type );
    }
}
